package com.sphd.beautysalon.adapters;

import android.widget.ImageView;

import com.android.volley.toolbox.ImageLoader;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sphd.beautysalon.utils.Constant;
import com.sphd.beautysalon.R;
import com.sphd.beautysalon.base.RestaurantsApplication;
import com.sphd.beautysalon.info.VipInfo;
import com.wzh.frame.utils.BigDisMailUtils;
import com.wzh.frame.utils.StringUtils;
import com.wzh.frame.views.RoundImageView;

import java.util.List;

/**
 * Created by Hu on 2017/1/19.
 */

public class RechargeAdapter extends BaseQuickAdapter<VipInfo> {
    public RechargeAdapter(int layoutResId, List<VipInfo> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, VipInfo vipInfo) {
        baseViewHolder
                .setText(R.id.vip_information, StringUtils.isEmpty(vipInfo.getMem_name())?"未填写":vipInfo.getMem_name() + "\t"+(StringUtils.isEmpty(vipInfo.getMem_card())?"无卡号":vipInfo.getMem_card()))
                .setText(R.id.time, vipInfo.getRegtime())
                .setText(R.id.vip_recharge, BigDisMailUtils.turnTrim(vipInfo.getTopup_money(), Constant.DECIMAL_POINT_TWO));
        RoundImageView roundImageView =baseViewHolder.getView(R.id.vip_img);
        setImage(roundImageView,vipInfo.getMem_photo());
    }
    public void setImage(ImageView image, String url) {
        ImageLoader imageLoader = RestaurantsApplication.getImageLoader();
        ImageLoader.ImageListener listener = ImageLoader.getImageListener(image,
                R.mipmap.moren, R.mipmap.moren);
        imageLoader.get(url, listener);
    }
}